<!DOCTYPE html>
<html lang="zh-CN">
    <head>
        <meta charset="UTF-8" />
        <title>28_案例练习-万年历</title>
    </head>
    <body>
        <span></span>

        <script>
            function getNowDate(){
                var date = new Date();

                var year = date.getFullYear();
                var month = date.getMonth() + 1;
                var day = date.getDate();

                var time = date.toLocaleTimeString();

                return '现在是:' + year + '年' + month + '月' + day + '日' + time;
            }

            var span = document.querySelector('span');
            setInterval(function(){
                span.innerHTML = getNowDate();
            },1000)

            
        </script>
    </body>
</html>